
package com.huizhan.web.dao;
 
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
import java.util.*;
import com.huizhan.web.model.*;


@Repository 
public interface AuthorizeDao extends JpaRepository<Authorize,Long>
{
    /**
     * 根据等级获取权限集合
     * @param level 等级
     * @return 权限集合
     */
    List<Authorize> findByLevel(Long level);
    
    /**
     * 根据项目角色ID获取权限集合
     * @param projectRoleId 项目角色ID
     * @return 权限集合
     */
    @Query(
        value = "SELECT a.* FROM authorize a"
            + " INNER JOIN role_authorize r ON a.authorize_id = r.authorize_id"+
              " WHERE r.project_role_id = ?1",
              nativeQuery = true)
    List<Authorize> findByProjectRoleId(Long projectRoleId);
}
